﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 了解委托
{
    internal class Publisher
    {
        public delegate void Receiver();
        public event Receiver receiverEvent;
        public void notifyAll()
        {
            if (receiverEvent != null)
            {
                receiverEvent();
            }
            else
            {
                MessageBox.Show("没有订阅者...");
            }
        }
    }
    class Subscriber
    {
        public void receiver()
        {
            MessageBox.Show("订阅者1：接收到消息了！");
        }
    }

    class Subscriber1
    {
        public void receiver1()
        {
            MessageBox.Show("订阅者2：接收到消息了！");
        }
    }

}
